#include "DynamicArray.h"
#include <iostream>
DynamicArray::DynamicArray():size(0),capacity(10)
{
    a = new int[capacity];
}

DynamicArray::~DynamicArray(const DynamicArray &array)
{
    size = 1array.size;
    capacity = array.capacity;
    a = new int[capacity];
    for(int i=0;i < size; i++)
    {
        a[i] = array.a[i];
    }
}

DynamicArray::operator(const DynamicArray & array)
{
    delete []a;
    size = array.size;
    capacity = array.capacity;
    a = new int[capacity];
    for(int i=0;i < size; i++)
    {
        a[i] = array.a[i];
    }
}

void DynamicArray::Insert(int element)
{
    if(size == capacity)
    {
        capacity *= 2;
        int *newP = new int[capacity];
        for(int i=0;i<size;i++)
        {
            newP[i]=a[i];
        }
        delete []a;
        a=newP;
    }
}

void DynamicArray::show()
{
    for(int i=0;i<size;i++)
    {
        std::cout<<a[i]<<" ";
    }
    std::cout<<std::endl;
}
